package com.lhf.personredis.controller;

import com.lhf.personredis.entity.Person;
import com.lhf.personredis.service.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
@RequestMapping("/person")
public class PersonController {
    @Autowired
    private PersonService service;
    //进入首页
    @RequestMapping("/index")
    public String toIndex(){
        return "index";
    }
    //查询人物
    @RequestMapping("/found")
    @ResponseBody
    public Object getPerson(@RequestParam(required = false,defaultValue = "") String name, @RequestParam(required = false,defaultValue = "-1")Integer sex,@RequestParam(required = false,defaultValue = "1") Integer pageindex){
       return service.getPerson(name,sex,pageindex);
    }
    //查询任务信息
    @RequestMapping("/info")
    @ResponseBody
    public Object getinfo(int id){
        return service.getinfo(id);
    }
    @RequestMapping("/del")
    @ResponseBody
    /*public Object del(int id){

    }*/
    //异常处理
    //@ExceptionHandler
    public String error(Exception e){
        return "error";
    }
}
